package com.njtoyo.taxi.admin.rest.controller.business.ride;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njtoyo.taxi.admin.aop.PermissionScope;
import com.njtoyo.taxi.admin.rest.presenter.business.ride.marking.RideMarkingDetailsPresenter;
import com.njtoyo.taxi.admin.rest.presenter.business.ride.marking.RideMarkingPagePresenter;
import com.njtoyo.taxi.admin.rest.presenter.business.ride.marking.TagListDataPresenter;
import com.njtoyo.taxi.admin.rest.wrapper.business.ride.marking.RideMarkingExportWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.business.ride.marking.RideMarkingWrapper;
import com.njtoyo.taxi.admin.service.business.ride.RideMarkingService;
import com.taxi.entity.common.RestResult;
import com.njtoyo.taxi.entity.backend.AdminUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;

@RestController
@Api(value = "评价管理", tags = {"评价管理"})
@RequestMapping("business/ride-marking")
public class RideMarkingController {
    @Autowired
    private RideMarkingService evaluationService;

    @GetMapping("/all")
    @ApiOperation(value = "评价标签", notes = "评价标签,权限:")
    RestResult<List<TagListDataPresenter>> tagList() {
        return evaluationService.tagList();
    }

    @GetMapping("")
    @ApiOperation(value = "评价列表", notes = "评价列表,权限:ride_marking_list")
    @PermissionScope(names = {"ride_marking_list"})
    RestResult<Page<RideMarkingPagePresenter>> evaluationList(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid RideMarkingWrapper wrapper) {
        return evaluationService.evaluationList(adminUser, wrapper);
    }

    @GetMapping("/export")
    @ApiOperation(value = "评价列表导出", notes = "评价列表导出,权限:ride_marking_export")
    @PermissionScope(names = {"ride_marking_export"})
    public RestResult export(@Valid RideMarkingExportWrapper wrapper,
                             @ApiIgnore @ModelAttribute("admin") AdminUser adminUser,
                             HttpServletResponse response) throws IOException {
        return evaluationService.export(wrapper, adminUser, response);
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "评价详情", notes = "评价详情,权限:ride_marking_detail")
    @PermissionScope(names = {"ride_marking_detail"})
    RestResult<RideMarkingDetailsPresenter> evaluationDetails(@PathVariable("id") Long id) {
        return evaluationService.evaluationDetails(id);
    }

}
